#pragma once
#include "Pascal.h"
#include "wc3main.h"
#include "wc3memory.h"
#include "wc3refcnt.h"
#include "wc3collections.h"

#include "wc3agent.h"
#include "wc3observer.h"

procedure wc3string_Init();
void wc3string_main();

	class TStringRep_VMT : public TRefCnt_VMT
	{
	public:
		procedure Dereference();
	};
	
	typedef TStringRep_VMT* PStringRep_VMT;

	class TStringRep : public TRefCnt
	{
	public:
		typedef THashKeyData<PChar> HashKeyData_Type;
	public:
		HashKeyData_Type HashKeyData;
	};

	typedef TStringRep* PStringRep;

	//template <class PStringRep>
	class TRCString : public TRefCnt
	{
	public:
		PStringRep FRepresentation;
	public:
		procedure SetRepresentation(PStringRep ARepresentation);
		procedure SetContent(PChar AString);
		PChar GetContent();
	public:
		//__declspec (property (get = FRepresentation, put = SetRepresentation)) PStringRep Representation;
		//__declspec (property (get = GetContent, put = SetContent)) PChar Content;
	public:
		procedure Clear();
		TRCString();
		~TRCString();
	};

	//typedef TRCString<PStringRep>* PRCString;
	typedef TRCString* PRCString;
	
	typedef TSHashTable<PChar, TStringRep, TStringHashKeyManager> FStorage_Type;

	struct THandle2AgentReg_2
	{
		Dword References;
		PAgent Value;
		LongBool AutoDestroy;
	};

	//template <class TStringHashKeyManager, class PStringRep, class TStringRep>
	class TStringManager
	{
	public:
		typedef TSHashTable<PChar, TStringRep, TStringHashKeyManager> FStorage_Type;
	public:
		FStorage_Type FStorage;
	public:
		PStringRep GetRepresentationFor(PChar AString);
		TStringManager();
		~TStringManager();
	};

	typedef TStringManager* PStringManager;
	//typedef TStringManager<TStringHashKeyManager,PStringRep,TStringRep>* PStringManager;

	//template <class TStringManager>
	PStringManager GetStringManager();
	//Pointer p_TStringManager_VMT;
	//PRCString p_TRCString_VMT;
	//PStringManager* ppStringManager;
	//PStringRep pNullRep;